forked from spf13/cobra
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update cobra #1
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dav-14
commented
Mar 15, 2024
•
edited
Loading
edited
- FROM 1.8.0
- feat: expose GetCompletions (was getCompletions)
Created a unit test that tests the unknown flag error message when the unknown flag is located in different arg positions.
Don't require contributors to install richgo but keep it as an option and for CI
…pf13#1851) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 3.2.0 to 3.3.1. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@v3.2.0...v3.3.1) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: David Wertenteil <dwertent@armosec.io>
Remove testing for go 1.15 to allow CI to pass, but don't force projects to upgrade.
`template` is an import in `cobra.go` file and also used as a variable name, which masks the library in the scope of that function.
Corrected the function name at the start of doc strings, as per the convention outlined in official go documentation: https://go.dev/blog/godoc
…pf13#1817) Fixes spf13#1816 Previously, arguments with a dash as the second character (e.g., 1-ff00:0:1) were detected as a flag by mistake. This resulted in auto completion misbehaving if such an argument was last in the argument list during invocation.
align documentation with the code : completions.go:452
Signed-off-by: John McBride <jpmmcbride@gmail.com>
This allows programs to request the shell to maintain the order of completions that was returned by the program
PowerShell 7.2 has changed the way arguments are passed to executables. This was originally an experimental feature in 7.2, but as of 7.3 it is built-in. A simple "" is now sufficient for passing empty arguments, no back-tick escaping is required. Fixes spf13#1849 Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com> Co-authored-by: Oldřich Jedlička <oldrich.jedlicka@rohlik.cz>
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
Although it is not the recommended approach, sourcing a completion script is the simplest way to get people to try using shell completion. Not allowing it for zsh has turned out to complicate shell completion adoption. Further, many tools modify the zsh script to allow sourcing. This commit allows sourcing of the zsh completion script. Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Fixes spf13#1880 Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com> Co-authored-by: Deleplace <deleplace2015@gmail.com>
The use in generated bash completion files is getting flagged by Lintian (the Debian package linting tool). Signed-off-by: Taavi Väänänen <hi@taavi.wtf>
Use temporary files instead of assuming the current directory is writable. Also, if creating a temporary file still returns an error, prevent the test from failing silently by replacing `log.Fatal` with `t.Fatal`.
This fixes an issue with program names that include a dot, in our case `podman.exe`. This was caused by the change in commit 6ba7ebb. Fixes spf13#1853 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Currently, only one of the persistent pre-runs and post-runs is executed. It is always the first one found in the parents chain, starting at this command. Expected behavior is to execute all parents' persistent pre-runs and post-runs. Dependent projects implemented various workarounds for this: - manually building persistent hook chains (in every hook). - applying some kind of monkey-patching on top of Cobra. This change eliminates the necessity for such workarounds by allowing to set a global variable EnableTraverseRunHooks. Tickets: - spf13#216 - spf13#252 Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
When using golangci-lint v1.55.0 some new errors were being reported. Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Fixes spf13#2060 When a command sets `DisableFlagParsing = true` it requests the responsibility of doing all the flag parsing. Therefore even the `--help/-f/--version/-v` flags should not be automatically completed by Cobra in such a case. Without this change the `--help/-h/--version/-v` flags can end up being completed twice for plugins: one time from cobra and one time from the plugin (which has set `DisableFlagParsing = true`). Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Different problems have been reported about flag completion registration. These two tests are the cases that were not being verified but had been mentioned as problematic. Ref: - spf13#1320 - spf13#1438 (comment) Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
…pf13#1940) * Replace all non-alphanumerics in active help env var program prefix There are other characters besides the dash that are fine in program names, but are problematic in environment variable names. These include (but are not limited to) period, space, and non-ASCII letters. * Another change in docs to mention non-ASCII-alphanumeric instead of just dash
In this case the executable is `kubectl-plugin`, but we run it as: kubectl plugin And the help text should reflect the actual usage of the command. To create a plugin, add the cobra.CommandDisplayNameAnnotation: rootCmd := &cobra.Command{ Use: "plugin", Annotations: map[string]string{ cobra.CommandDisplayNameAnnotation: "kubectl plugin", } } Internally this change modifies CommandPath() for the root command to return the command display name instead of the command name. This is used for error messages, help text generation, and completions. CommandPath() is expected to have spaces and code using it already handle spaces (e.g replacing with _), so hopefully this does not break anything. Fixes: spf13#2017 Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The new API is simpler and matches the `c.RegisterFlagCompletionFunc()` API. By removing the global function `GetFlagCompletion()` we are more future proof if we ever move from a global map of flag completion functions to something associated with the command. The commit also makes this API work with persistent flags by using `c.Flag(flagName)` instead of `c.Flags().Lookup(flagName)`. The commit also adds unit tests. Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
Dav-14
force-pushed
the
feat/update_cobra
branch
from
March 15, 2024 11:16
703a296
to
bfd8d9b
Compare
This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.